package com.ruoyi.whole.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.evaluate.infoprojectevaluate.domain.InfoProjectEvaluate;
import com.ruoyi.whole.domain.InfoBulkIndexAddVo;
import com.ruoyi.whole.domain.InfoBulkPlanAddVo;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.whole.domain.InfoWholeIndex;
import com.ruoyi.whole.service.IInfoWholeIndexService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 目标管理-部门整体-指标详情Controller
 *
 * @author ruoyi
 * @date 2022-02-09
 */
@RestController
@RequestMapping("/whole/index")
public class InfoWholeIndexController extends BaseController
{
    @Autowired
    private IInfoWholeIndexService infoWholeIndexService;

    /**
     * 查询目标管理-部门整体-指标详情列表
     */
    @PreAuthorize("@ss.hasPermi('whole:index:list')")
    @GetMapping("/list")
    public TableDataInfo list(InfoWholeIndex infoWholeIndex)
    {
        startPage();
        List<InfoWholeIndex> list = infoWholeIndexService.selectInfoWholeIndexList(infoWholeIndex);
        return getDataTable(list);
    }

    /**
     * 导出目标管理-部门整体-指标详情列表
     */
    @PreAuthorize("@ss.hasPermi('whole:index:export')")
    @Log(title = "目标管理-部门整体-指标详情", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, InfoWholeIndex infoWholeIndex)
    {
        List<InfoWholeIndex> list = infoWholeIndexService.selectInfoWholeIndexList(infoWholeIndex);
        ExcelUtil<InfoWholeIndex> util = new ExcelUtil<InfoWholeIndex>(InfoWholeIndex.class);
        util.exportExcel(response, list, "目标管理-部门整体-指标详情数据");
    }

    /**
     * 获取目标管理-部门整体-指标详情详细信息
     */
    @PreAuthorize("@ss.hasPermi('whole:index:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(infoWholeIndexService.selectInfoWholeIndexById(id));
    }

    /**
     * 新增目标管理-部门整体-指标详情
     */
    @PreAuthorize("@ss.hasPermi('whole:index:add')")
    @Log(title = "目标管理-部门整体-指标详情", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody InfoWholeIndex infoWholeIndex)
    {
        return toAjax(infoWholeIndexService.insertInfoWholeIndex(infoWholeIndex));
    }

    /**
     * 修改目标管理-部门整体-指标详情
     */
    @PreAuthorize("@ss.hasPermi('whole:index:edit')")
    @Log(title = "目标管理-部门整体-指标详情", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody InfoWholeIndex infoWholeIndex)
    {
        return toAjax(infoWholeIndexService.updateInfoWholeIndex(infoWholeIndex));
    }

    /**
     * 删除目标管理-部门整体-指标详情
     */
    @PreAuthorize("@ss.hasPermi('whole:index:remove')")
    @Log(title = "目标管理-部门整体-指标详情", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(infoWholeIndexService.deleteInfoWholeIndexByIds(ids));
    }

    /**
     *批量新增
     *
     */
    @RequestMapping(value = "/addBulkIndex", method = RequestMethod.POST)
    @ApiOperation("批量新增")
    @ApiImplicitParam(name = "infoBulkIndexAddVo", value = "实体类", dataType = "InfoBulkIndexAddVo")
    public AjaxResult addBulkIndex(@RequestBody InfoBulkIndexAddVo infoBulkIndexAddVo)
    {
        return toAjax( infoWholeIndexService.batchInsert(infoBulkIndexAddVo));
    }

    /**
     * 评价填报里修改的指标
     * @param infoWholeIndex
     * @return
     */
    @PostMapping(value = "/xg")
    public AjaxResult xglist(@RequestBody InfoWholeIndex infoWholeIndex){
        return AjaxResult.success(infoWholeIndexService.xgList(infoWholeIndex));
    }

    /**
     * 上传文件
     */
    @RequestMapping(value = "/uploadFiles", method = RequestMethod.POST)
    public AjaxResult uploadFiles(@RequestBody  InfoWholeIndex infoWholeIndex) {
        return toAjax(infoWholeIndexService.uploadFiles(infoWholeIndex));
    }
}
